package net.freestu.sola.web.global;

import java.io.File;
import java.io.IOException;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;

/**
 * 这个类读取文件.然后生成蜘蛛进行爬行，然后搜集数据.
 * @author 秋刀鱼的滋味
 *
 */
public class ConfigReader {
    
	private File config;
	private static Element conf;
	
	public ConfigReader(File config){
		
		this.config=config;
		read();
	}
	/**
	 * 读取文件，然后 
	 */
	private void read(){
		
		SAXBuilder builder = new SAXBuilder();
        
		Document read_doc=null;
		try {
			read_doc = builder.build(config);
		} catch (JDOMException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
           conf = read_doc.getRootElement();
	}
	
	public static String getConfigText(String str){
		
		return conf.getChildText(str);
	}
	
	public static void main(String[] args){
		
		File f=new File("D://config.xml");
		ConfigReader cr=new ConfigReader(f);
		String dd=ConfigReader.getConfigText("page_charset");
		System.out.println(dd);
	}
}
